package com.apes.fico.masterdata.gl.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @program: apestech
 * @description: 科目表分配公司
 * @author: Chengxm
 * @create: 2018-12-26 15:25
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = AccountingChartDistributionCompany.CONST_TABLE_NAME,indexes = {
        @Index(columnList = "company_id",unique = true)
})
public class AccountingChartDistributionCompany extends Model {

    public final static String CONST_TABLE_NAME ="mas_acc_chart_company";

    @Id
    @Column(name = "id", length = 8)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "科目表分配公司")
    @Comment("编号")
    private String id;

    @NotNull
    @Comment("所属会计科目表")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "acc_system_id", referencedColumnName = "id")
    private AccountingSystem accSystem;

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", referencedColumnName = "id")
    private PartyRole company;

}
